/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package vn.com.sml.SEFM.BUS;

import java.util.Iterator;
import java.util.List;
import javax.persistence.RollbackException;
import javax.transaction.HeuristicMixedException;
import javax.transaction.HeuristicRollbackException;
import javax.transaction.SystemException;
import vn.com.sml.SEFM.DAO.UserStatusDAO;
import vn.com.sml.SEFM.domain.Userstatus;
/**
 *
 * @author Tunp
 */
public class UserStatusBUS {
        
    public static Integer saveUserstatus(Userstatus userstatus) throws SecurityException, RollbackException, HeuristicRollbackException, HeuristicMixedException, IllegalStateException, SystemException {
        return UserStatusDAO.saveUserstatus(userstatus);
    }
   
    public static List<Userstatus> listUserstatus() throws RollbackException, HeuristicMixedException, HeuristicRollbackException, SecurityException, SystemException{
        return UserStatusDAO.listUserstatus();
    }

    public Userstatus getUserstatusById(int id) throws RollbackException, HeuristicMixedException, HeuristicRollbackException, SecurityException, IllegalStateException, SystemException {
        List<Userstatus> lstUS = UserStatusDAO.listUserstatus();
        if(lstUS.isEmpty())
            return null;
        for (Iterator<Userstatus> it = lstUS.iterator(); it.hasNext();) {
            Userstatus userstatus = it.next();
            if(userstatus.getStatusId() == id)
                return userstatus;
        }
        return null;
    }
}
